export const isBrowser = typeof window !== "undefined";
export const isDef = <T = any>(val?: T): val is T => typeof val !== "undefined";
export const isBoolean = (val: any): val is boolean => typeof val === "boolean";
export const isFunction = <T extends Function>(val: any): val is T =>
  typeof val === "function";
export const isNumber = (val: any): val is number => typeof val === "number";
export const isString = (val: unknown): val is string =>
  typeof val === "string";
export const isObject = (val: any): val is object =>
  toString.call(val) === "[object Object]";
export const isWindow = (val: any): val is Window =>
  typeof window !== "undefined" && toString.call(val) === "[object Window]";

// 正整数
export const isStringNumber = (str: string): boolean => {
  return /^[0-9]*[1-9][0-9]*$/.test(str);
};
